home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / emacs-complete / fsf / emacs / lisp / info.el < prev    next >
Lisp/Scheme  |  1994-09-03  |  60KB  |  1,667 lines

  1. ;;; info.el --- info package for Emacs.
  2.  
  3. ;; Copyright (C) 1985, 1986, 1992, 1993, 1994 Free Software Foundation, Inc.
  4.  
  5. ;; Maintainer: FSF
  6. ;; Keywords: help
  7.  
  8. ;; This file is part of GNU Emacs.
  9.  
  10. ;; GNU Emacs is free software; you can redistribute it and/or modify
  11. ;; it under the terms of the GNU General Public License as published by
  12. ;; the Free Software Foundation; either version 2, or (at your option)
  13. ;; any later version.
  14.  
  15. ;; GNU Emacs is distributed in the hope that it will be useful,
  16. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. ;; GNU General Public License for more details.
  19.  
  20. ;; You should have received a copy of the GNU General Public License
  21. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  22. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  
  24. ;;; Commentary:
  25.  
  26. ;;; Note that nowadays we expect info files to be made using makeinfo.
  27.  
  28. ;;; Code:
  29.  
  30. (defvar Info-history nil
  31.   "List of info nodes user has visited.
  32. Each element of list is a list (FILENAME NODENAME BUFFERPOS).")
  33.  
  34. (defvar Info-enable-edit nil
  35.   "*Non-nil means the \\<Info-mode-map>\\[Info-edit] command in Info can edit the current node.
  36. This is convenient if you want to write info files by hand.
  37. However, we recommend that you not do this.
  38. It is better to write a Texinfo file and generate the Info file from that,
  39. because that gives you a printed manual as well.")
  40.  
  41. (defvar Info-enable-active-nodes t
  42.   "Non-nil allows Info to execute Lisp code associated with nodes.
  43. The Lisp code is executed when the node is selected.")
  44.  
  45. (defvar Info-default-directory-list nil
  46.   "List of default directories to search for Info documentation files.
  47. This value is used as the default for `Info-directory-list'.  It is set
  48. in paths.el.")
  49.  
  50. (defvar Info-fontify t
  51.   "*Non-nil enables highlighting and fonts in Info nodes.")
  52.  
  53. (defvar Info-fontify-maximum-menu-size 30000
  54.   "*Maximum size of menu to fontify if `Info-fontify' is non-nil.")
  55.  
  56. (defvar Info-directory-list
  57.   (let ((path (getenv "INFOPATH"))
  58.     (sep (if (eq system-type 'ms-dos) ";" ":"))
  59.     (sibling (expand-file-name "../info/" (invocation-directory))))
  60.     (if path
  61.     (let ((list nil)
  62.           idx)
  63.       (while (> (length path) 0)
  64.         (setq idx (or (string-match sep path) (length path))
  65.           list (cons (substring path 0 idx) list)
  66.           path (substring path (min (1+ idx)
  67.                         (length path)))))
  68.       (nreverse list))
  69.       (if (or (member sibling Info-default-directory-list)
  70.           (not (file-exists-p sibling))
  71.           ;; On MS-DOS, we use movable executables always,
  72.           ;; and we must always find the Info dir at run time.
  73.           (if (eq system-type 'ms-dos)
  74.           nil
  75.         ;; Use invocation-directory for Info only if we used it for
  76.         ;; exec-directory also.
  77.         (not (string= exec-directory
  78.                   (expand-file-name "../lib-src/"
  79.                         (invocation-directory))))))
  80.       Info-default-directory-list
  81.     (reverse (cons sibling (cdr (reverse Info-default-directory-list)))))))
  82.   "List of directories to search for Info documentation files.
  83. nil means not yet initialized.  In this case, Info uses the environment
  84. variable INFOPATH to initialize it, or `Info-default-directory-list'
  85. if there is no INFOPATH variable in the environment.
  86. The last element of `Info-default-directory-list' is the directory
  87. where Emacs installs the Info files that come with it.
  88.  
  89. If you run the Emacs executable from the `src' directory in the Emacs
  90. source tree, the `info' directory in the source tree is used as the last
  91. element, in place of the installation Info directory.  This is useful
  92. when you run a version of Emacs without installing it.")
  93.  
  94. (defvar Info-additional-directory-list nil
  95.   "List of additional directories to search for Info documentation files.
  96. These directories are not searched for merging the `dir' file.")
  97.  
  98. (defvar Info-current-file nil
  99.   "Info file that Info is now looking at, or nil.")
  100.  
  101. (defvar Info-current-subfile nil
  102.   "Info subfile that is actually in the *info* buffer now,
  103. or nil if current info file is not split into subfiles.")
  104.  
  105. (defvar Info-current-node nil
  106.   "Name of node that Info is now looking at, or nil.")
  107.  
  108. (defvar Info-tag-table-marker (make-marker)
  109.   "Marker pointing at beginning of current Info file's tag table.
  110. Marker points nowhere if file has no tag table.")
  111.  
  112. (defvar Info-current-file-completions nil
  113.   "Cached completion list for current Info file.")
  114.  
  115. (defvar Info-index-alternatives nil
  116.   "List of possible matches for last Info-index command.")
  117.  
  118. (defvar Info-standalone nil
  119.   "Non-nil if Emacs was started solely as an Info browser.")
  120.  
  121. (defvar Info-suffix-list '( (".info.Z"  . "uncompress")
  122.                 (".info.Y"  . "unyabba")
  123.                 (".info.gz" . "gunzip")
  124.                 (".info.z"  . "gunzip")
  125.                 (".info"    . nil)
  126.                 (".Z"       . "uncompress")
  127.                 (".Y"       . "unyabba")
  128.                 (".gz"      . "gunzip")
  129.                 (".z"       . "gunzip")
  130.                 (""         . nil))
  131.   "List of file name suffixes and associated decoding commands.
  132. Each entry should be (SUFFIX . STRING); the file is given to
  133. the command as standard input.  If STRING is nil, no decoding is done.
  134. Because the SUFFIXes are tried in order, the empty string should
  135. be last in the list.")
  136.  
  137. (defun info-insert-file-contents (filename &optional visit)
  138.   "Insert the contents of an info file in the current buffer.
  139. Do the right thing if the file has been compressed or zipped."
  140.   (let ((tail Info-suffix-list)
  141.     fullname decoder)
  142.     (if (file-exists-p filename)
  143.     (progn
  144.       (while (and tail
  145.               (not (string-match
  146.                 (concat (regexp-quote (car (car tail))) "$")
  147.                 filename)))
  148.         (setq tail (cdr tail)))
  149.       (setq fullname filename
  150.         decoder (cdr (car tail))))
  151.       (while (and tail
  152.           (not (file-exists-p (concat filename (car (car tail))))))
  153.     (setq tail (cdr tail)))
  154.       (setq fullname (concat filename (car (car tail)))
  155.         decoder (cdr (car tail)))
  156.       ;; check for conflict with jka-compr
  157.       (if (and (featurep 'jka-compr)
  158.            (jka-compr-installed-p)
  159.            (jka-compr-get-compression-info (concat filename
  160.                                (car (car tail)))))
  161.       (setq decoder nil))
  162.       (or tail
  163.       (error "Can't find %s or any compressed version of it!" filename)))
  164.     (insert-file-contents fullname visit)
  165.     (if decoder
  166.     (let ((buffer-read-only nil))
  167.       (shell-command-on-region (point-min) (point-max) decoder t)))))
  168.  
  169. ;;;###autoload
  170. (defun info (&optional file)
  171.   "Enter Info, the documentation browser.
  172. Optional argument FILE specifies the file to examine;
  173. the default is the top-level directory of Info.
  174.  
  175. In interactive use, a prefix argument directs this command
  176. to read a file name from the minibuffer."
  177.   (interactive (if current-prefix-arg
  178.            (list (read-file-name "Info file name: " nil nil t))))
  179.   (if file
  180.       (Info-goto-node (concat "(" file ")"))
  181.     (if (get-buffer "*info*")
  182.     (switch-to-buffer "*info*")
  183.       (Info-directory))))
  184.  
  185. ;;;###autoload
  186. (defun info-standalone ()
  187.   "Run Emacs as a standalone Info reader.
  188. Usage:  emacs -f info-standalone [filename]
  189. In standalone mode, \\<Info-mode-map>\\[Info-exit] exits Emacs itself."
  190.   (setq Info-standalone t)
  191.   (if (and command-line-args-left
  192.        (not (string-match "^-" (car command-line-args-left))))
  193.       (condition-case err
  194.       (progn
  195.         (info (car command-line-args-left))
  196.         (setq command-line-args-left (cdr command-line-args-left)))
  197.     (error (send-string-to-terminal
  198.         (format "%s\n" (if (eq (car-safe err) 'error)
  199.                    (nth 1 err) err)))
  200.            (save-buffers-kill-emacs)))
  201.     (info)))
  202.  
  203. ;; Go to an info node specified as separate filename and nodename.
  204. ;; no-going-back is non-nil if recovering from an error in this function;
  205. ;; it says do not attempt further (recursive) error recovery.
  206. (defun Info-find-node (filename nodename &optional no-going-back)
  207.   ;; Convert filename to lower case if not found as specified.
  208.   ;; Expand it.
  209.   (if filename
  210.       (let (temp temp-downcase found)
  211.     (setq filename (substitute-in-file-name filename))
  212.     (if (string= (downcase (file-name-nondirectory filename)) "dir")
  213.         (setq found t)
  214.       (let ((dirs (if (string-match "^\\./" filename)
  215.               ;; If specified name starts with `./'
  216.               ;; then just try current directory.
  217.               '("./")
  218.             (if Info-additional-directory-list
  219.                 (append Info-directory-list
  220.                     Info-additional-directory-list)
  221.               Info-directory-list))))
  222.         ;; Search the directory list for file FILENAME.
  223.         (while (and dirs (not found))
  224.           (setq temp (expand-file-name filename (car dirs)))
  225.           (setq temp-downcase
  226.             (expand-file-name (downcase filename) (car dirs)))
  227.           ;; Try several variants of specified name.
  228.           (let ((suffix-list Info-suffix-list))
  229.         (while (and suffix-list (not found))
  230.           (cond ((file-exists-p
  231.               (concat temp (car (car suffix-list))))
  232.              (setq found temp))
  233.             ((file-exists-p
  234.               (concat temp-downcase (car (car suffix-list))))
  235.              (setq found temp-downcase)))
  236.           (setq suffix-list (cdr suffix-list))))
  237.           (setq dirs (cdr dirs)))))
  238.     (if found
  239.         (setq filename found)
  240.       (error "Info file %s does not exist" filename))))
  241.   ;; Record the node we are leaving.
  242.   (if (and Info-current-file (not no-going-back))
  243.       (setq Info-history
  244.         (cons (list Info-current-file Info-current-node (point))
  245.           Info-history)))
  246.   ;; Go into info buffer.
  247.   (switch-to-buffer "*info*")
  248.   (buffer-disable-undo (current-buffer))
  249.   (or (eq major-mode 'Info-mode)
  250.       (Info-mode))
  251.   (widen)
  252.   (setq Info-current-node nil)
  253.   (unwind-protect
  254.       (progn
  255.     ;; Switch files if necessary
  256.     (or (null filename)
  257.         (equal Info-current-file filename)
  258.         (let ((buffer-read-only nil))
  259.           (setq Info-current-file nil
  260.             Info-current-subfile nil
  261.             Info-current-file-completions nil
  262.             Info-index-alternatives nil
  263.             buffer-file-name nil)
  264.           (erase-buffer)
  265.           (if (eq filename t)
  266.           (Info-insert-dir)
  267.         (info-insert-file-contents filename t)
  268.         (setq default-directory (file-name-directory filename)))
  269.           (set-buffer-modified-p nil)
  270.           ;; See whether file has a tag table.  Record the location if yes.
  271.           (set-marker Info-tag-table-marker nil)
  272.           (goto-char (point-max))
  273.           (forward-line -8)
  274.           (or (equal nodename "*")
  275.           (not (search-forward "\^_\nEnd tag table\n" nil t))
  276.           (let (pos)
  277.             ;; We have a tag table.  Find its beginning.
  278.             ;; Is this an indirect file?
  279.             (search-backward "\nTag table:\n")
  280.             (setq pos (point))
  281.             (if (save-excursion
  282.               (forward-line 2)
  283.               (looking-at "(Indirect)\n"))
  284.             ;; It is indirect.  Copy it to another buffer
  285.             ;; and record that the tag table is in that buffer.
  286.             (save-excursion
  287.               (let ((buf (current-buffer)))
  288.                 (set-buffer (get-buffer-create " *info tag table*"))
  289.                             (buffer-disable-undo (current-buffer))
  290.                 (setq case-fold-search t)
  291.                 (erase-buffer)
  292.                 (insert-buffer-substring buf)
  293.                 (set-marker Info-tag-table-marker
  294.                     (match-end 0))))
  295.               (set-marker Info-tag-table-marker pos))))
  296.           (setq Info-current-file
  297.             (if (eq filename t) "dir"
  298.               (file-name-sans-versions buffer-file-name)))))
  299.     (if (equal nodename "*")
  300.         (progn (setq Info-current-node nodename)
  301.            (Info-set-mode-line))
  302.       ;; Search file for a suitable node.
  303.       (let ((guesspos (point-min))
  304.         (regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n\177]")))
  305.         ;; First get advice from tag table if file has one.
  306.         ;; Also, if this is an indirect info file,
  307.         ;; read the proper subfile into this buffer.
  308.         (if (marker-position Info-tag-table-marker)
  309.         (save-excursion
  310.           (set-buffer (marker-buffer Info-tag-table-marker))
  311.           (goto-char Info-tag-table-marker)
  312.           (if (re-search-forward regexp nil t)
  313.               (progn
  314.             (setq guesspos (read (current-buffer)))
  315.             ;; If this is an indirect file,
  316.             ;; determine which file really holds this node
  317.             ;; and read it in.
  318.             (if (not (eq (current-buffer) (get-buffer "*info*")))
  319.                 (setq guesspos
  320.                   (Info-read-subfile guesspos))))
  321.             (error "No such node: \"%s\"" nodename))))
  322.         (goto-char (max (point-min) (- guesspos 1000)))
  323.         ;; Now search from our advised position (or from beg of buffer)
  324.         ;; to find the actual node.
  325.         (catch 'foo
  326.           (while (search-forward "\n\^_" nil t)
  327.         (forward-line 1)
  328.         (let ((beg (point)))
  329.           (forward-line 1)
  330.           (if (re-search-backward regexp beg t)
  331.               (throw 'foo t))))
  332.           (error "No such node: %s" nodename)))
  333.       (Info-select-node)))
  334.     ;; If we did not finish finding the specified node,
  335.     ;; go back to the previous one.
  336.     (or Info-current-node no-going-back (null Info-history)
  337.     (let ((hist (car Info-history)))
  338.       (setq Info-history (cdr Info-history))
  339.       (Info-find-node (nth 0 hist) (nth 1 hist) t)
  340.       (goto-char (nth 2 hist)))))
  341.   (goto-char (point-min)))
  342.  
  343. ;; Cache the contents of the (virtual) dir file, once we have merged
  344. ;; it for the first time, so we can save time subsequently.
  345. (defvar Info-dir-contents nil)
  346.  
  347. ;; Cache for the directory we decided to use for the default-directory
  348. ;; of the merged dir text.
  349. (defvar Info-dir-contents-directory nil)
  350.  
  351. ;; Record the file attributes of all the files from which we
  352. ;; constructed Info-dir-contents.
  353. (defvar Info-dir-file-attributes nil)
  354.  
  355. ;; Construct the Info directory node by merging the files named `dir'
  356. ;; from various directories.  Set the *info* buffer's
  357. ;; default-directory to the first directory we actually get any text
  358. ;; from.
  359. (defun Info-insert-dir ()
  360.   (if (and Info-dir-contents Info-dir-file-attributes
  361.        ;; Verify that none of the files we used has changed
  362.        ;; since we used it.
  363.        (eval (cons 'and
  364.                (mapcar '(lambda (elt)
  365.                   (let ((curr (file-attributes (car elt))))
  366.                     ;; Don't compare the access time.
  367.                     (if curr (setcar (nthcdr 4 curr) 0))
  368.                     (setcar (nthcdr 4 (cdr elt)) 0)
  369.                     (equal (cdr elt) curr)))
  370.                    Info-dir-file-attributes))))
  371.       (insert Info-dir-contents)
  372.     (let ((dirs Info-directory-list)
  373.       buffers buffer others nodes dirs-done)
  374.  
  375.       (setq Info-dir-file-attributes nil)
  376.  
  377.       ;; Search the directory list for the directory file.
  378.       (while dirs
  379.     (let ((truename (file-truename (expand-file-name (car dirs)))))
  380.       (or (member truename dirs-done)
  381.           (member (directory-file-name truename) dirs-done)
  382.           ;; Try several variants of specified name.
  383.           ;; Try upcasing, appending `.info', or both.
  384.           (let* (file
  385.              (attrs
  386.               (or
  387.                (progn (setq file (expand-file-name "dir" truename))
  388.                   (file-attributes file))
  389.                (progn (setq file (expand-file-name "DIR" truename))
  390.                   (file-attributes file))
  391.                (progn (setq file (expand-file-name "dir.info" truename))
  392.                   (file-attributes file))
  393.                (progn (setq file (expand-file-name "DIR.INFO" truename))
  394.                   (file-attributes file)))))
  395.         (setq dirs-done
  396.               (cons truename
  397.                 (cons (directory-file-name truename)
  398.                   dirs-done)))
  399.         (if attrs
  400.             (save-excursion
  401.               (or buffers
  402.               (message "Composing main Info directory..."))
  403.               (set-buffer (generate-new-buffer "info dir"))
  404.               (insert-file-contents file)
  405.               (setq buffers (cons (current-buffer) buffers)
  406.                 Info-dir-file-attributes
  407.                 (cons (cons file attrs)
  408.                   Info-dir-file-attributes))))))
  409.       (setq dirs (cdr dirs))))
  410.       
  411.       (or buffers
  412.       (error "Can't find the info directory node"))
  413.       ;; Distinguish the dir file that comes with Emacs from all the
  414.       ;; others.  Yes, that is really what this is supposed to do.
  415.       ;; If it doesn't work, fix it.
  416.       (setq buffer (car buffers)
  417.         others (cdr buffers))
  418.  
  419.       ;; Insert the entire original dir file as a start; use its
  420.       ;; default directory as the default directory for the whole
  421.       ;; concatenation.
  422.       (insert-buffer buffer)
  423.       (setq Info-dir-contents-directory (save-excursion
  424.                       (set-buffer buffer)
  425.                       default-directory))
  426.  
  427.       ;; Look at each of the other buffers one by one.
  428.       (while others
  429.     (let ((other (car others)))
  430.       ;; In each, find all the menus.
  431.       (save-excursion
  432.         (set-buffer other)
  433.         (goto-char (point-min))
  434.         ;; Find each menu, and add an elt to NODES for it.
  435.         (while (re-search-forward "^\\* Menu:" nil t)
  436.           (let (beg nodename end)
  437.         (forward-line 1)
  438.         (setq beg (point))
  439.         (search-backward "\n\^_")
  440.         (search-forward "Node: ")
  441.         (setq nodename (Info-following-node-name))
  442.         (search-forward "\n\^_" nil 'move)
  443.         (beginning-of-line)
  444.         (setq end (point))
  445.         (setq nodes (cons (list nodename other beg end) nodes))))))
  446.     (setq others (cdr others)))
  447.       ;; Add to the main menu a menu item for each other node.
  448.       (re-search-forward "^\\* Menu:")
  449.       (forward-line 1)
  450.       (let ((menu-items '("top"))
  451.         (nodes nodes)
  452.         (case-fold-search t)
  453.         (end (save-excursion (search-forward "\^_" nil t) (point))))
  454.     (while nodes
  455.       (let ((nodename (car (car nodes))))
  456.         (save-excursion
  457.           (or (member (downcase nodename) menu-items)
  458.           (re-search-forward (concat "^\\* "
  459.                          (regexp-quote nodename)
  460.                          "::")
  461.                      end t)
  462.           (progn
  463.             (insert "* " nodename "::" "\n")
  464.             (setq menu-items (cons nodename menu-items))))))
  465.       (setq nodes (cdr nodes))))
  466.       ;; Now take each node of each of the other buffers
  467.       ;; and merge it into the main buffer.
  468.       (while nodes
  469.     (let ((nodename (car (car nodes))))
  470.       (goto-char (point-min))
  471.       ;; Find the like-named node in the main buffer.
  472.       (if (re-search-forward (concat "\n\^_.*\n.*Node: "
  473.                      (regexp-quote nodename)
  474.                      "[,\n\t]")
  475.                  nil t)
  476.           (progn
  477.         (search-forward "\n\^_" nil 'move)
  478.         (beginning-of-line))
  479.         ;; If none exists, add one.
  480.         (goto-char (point-max))
  481.         (insert "\^_\nFile: dir\tNode: " nodename "\n\n* Menu:\n\n"))
  482.       ;; Merge the text from the other buffer's menu
  483.       ;; into the menu in the like-named node in the main buffer.
  484.       (apply 'insert-buffer-substring (cdr (car nodes)))
  485.       (insert "\n"))
  486.     (setq nodes (cdr nodes)))
  487.       ;; Kill all the buffers we just made.
  488.       (while buffers
  489.     (kill-buffer (car buffers))
  490.     (setq buffers (cdr buffers)))
  491.       (message "Composing main Info directory...done"))
  492.     (setq Info-dir-contents (buffer-string)))
  493.   (setq default-directory Info-dir-contents-directory))
  494.  
  495. (defun Info-read-subfile (nodepos)
  496.   (set-buffer (marker-buffer Info-tag-table-marker))
  497.   (goto-char (point-min))
  498.   (search-forward "\n\^_")
  499.   (let (lastfilepos
  500.     lastfilename)
  501.     (forward-line 2)
  502.     (catch 'foo
  503.       (while (not (looking-at "\^_"))
  504.     (if (not (eolp))
  505.         (let ((beg (point))
  506.           thisfilepos thisfilename)
  507.           (search-forward ": ")
  508.           (setq thisfilename  (buffer-substring beg (- (point) 2)))
  509.           (setq thisfilepos (read (current-buffer)))
  510.           ;; read in version 19 stops at the end of number.
  511.           ;; Advance to the next line.
  512.           (forward-line 1)
  513.           (if (> thisfilepos nodepos)
  514.           (throw 'foo t))
  515.           (setq lastfilename thisfilename)
  516.           (setq lastfilepos thisfilepos))
  517.       (forward-line 1))))
  518.     (set-buffer (get-buffer "*info*"))
  519.     (or (equal Info-current-subfile lastfilename)
  520.     (let ((buffer-read-only nil))
  521.       (setq buffer-file-name nil)
  522.       (widen)
  523.       (erase-buffer)
  524.       (info-insert-file-contents lastfilename)
  525.       (set-buffer-modified-p nil)
  526.       (setq Info-current-subfile lastfilename)))
  527.     (goto-char (point-min))
  528.     (search-forward "\n\^_")
  529.     (+ (- nodepos lastfilepos) (point))))
  530.  
  531. ;; Select the info node that point is in.
  532. (defun Info-select-node ()
  533.   (save-excursion
  534.    ;; Find beginning of node.
  535.    (search-backward "\n\^_")
  536.    (forward-line 2)
  537.    ;; Get nodename spelled as it is in the node.
  538.    (re-search-forward "Node:[ \t]*")
  539.    (setq Info-current-node
  540.      (buffer-substring (point)
  541.                (progn
  542.                 (skip-chars-forward "^,\t\n")
  543.                 (point))))
  544.    (Info-set-mode-line)
  545.    ;; Find the end of it, and narrow.
  546.    (beginning-of-line)
  547.    (let (active-expression)
  548.      (narrow-to-region (point)
  549.                (if (re-search-forward "\n[\^_\f]" nil t)
  550.                (prog1
  551.                 (1- (point))
  552.                 (if (looking-at "[\n\^_\f]*execute: ")
  553.                 (progn
  554.                   (goto-char (match-end 0))
  555.                   (setq active-expression
  556.                     (read (current-buffer))))))
  557.              (point-max)))
  558.      (if Info-enable-active-nodes (eval active-expression))
  559.      (if Info-fontify (Info-fontify-node))
  560.      (run-hooks 'Info-selection-hook))))
  561.  
  562. (defun Info-set-mode-line ()
  563.   (setq mode-line-buffer-identification
  564.     (concat
  565.      "Info:  ("
  566.      (if Info-current-file
  567.          (file-name-nondirectory Info-current-file)
  568.        "")
  569.      ")"
  570.      (or Info-current-node ""))))
  571.  
  572. ;; Go to an info node specified with a filename-and-nodename string
  573. ;; of the sort that is found in pointers in nodes.
  574.  
  575. (defun Info-goto-node (nodename)
  576.   "Go to info node named NAME.  Give just NODENAME or (FILENAME)NODENAME."
  577.   (interactive (list (Info-read-node-name "Goto node: ")))
  578.   (let (filename)
  579.     (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)"
  580.           nodename)
  581.     (setq filename (if (= (match-beginning 1) (match-end 1))
  582.                ""
  583.              (substring nodename (match-beginning 2) (match-end 2)))
  584.       nodename (substring nodename (match-beginning 3) (match-end 3)))
  585.     (let ((trim (string-match "\\s *\\'" filename)))
  586.       (if trim (setq filename (substring filename 0 trim))))
  587.     (let ((trim (string-match "\\s *\\'" nodename)))
  588.       (if trim (setq nodename (substring nodename 0 trim))))
  589.     (Info-find-node (if (equal filename "") nil filename)
  590.             (if (equal nodename "") "Top" nodename))))
  591.  
  592. (defun Info-read-node-name (prompt &optional default)
  593.   (let* ((completion-ignore-case t)
  594.      (nodename (completing-read prompt (Info-build-node-completions))))
  595.     (if (equal nodename "")
  596.     (or default
  597.         (Info-read-node-name prompt))
  598.       nodename)))
  599.  
  600. (defun Info-build-node-completions ()
  601.   (or Info-current-file-completions
  602.       (let ((compl nil))
  603.     (save-excursion
  604.       (save-restriction
  605.         (if (marker-buffer Info-tag-table-marker)
  606.         (progn
  607.           (set-buffer (marker-buffer Info-tag-table-marker))
  608.           (widen)
  609.           (goto-char Info-tag-table-marker)
  610.           (while (re-search-forward "\nNode: \\(.*\\)\177" nil t)
  611.             (setq compl
  612.               (cons (list (buffer-substring (match-beginning 1)
  613.                             (match-end 1)))
  614.                 compl))))
  615.           (widen)
  616.           (goto-char (point-min))
  617.           (while (search-forward "\n\^_" nil t)
  618.         (forward-line 1)
  619.         (let ((beg (point)))
  620.           (forward-line 1)
  621.           (if (re-search-backward "Node: *\\([^,\n]*\\) *[,\n\t]"
  622.                       beg t)
  623.               (setq compl 
  624.                 (cons (list (buffer-substring (match-beginning 1)
  625.                               (match-end 1)))
  626.                   compl))))))))
  627.     (setq Info-current-file-completions compl))))
  628.  
  629. (defun Info-restore-point (hl)
  630.   "If this node has been visited, restore the point value when we left."
  631.   (while hl
  632.     (if (and (equal (nth 0 (car hl)) Info-current-file)
  633.          (equal (nth 1 (car hl)) Info-current-node))
  634.     (progn
  635.       (goto-char (nth 2 (car hl)))
  636.       (setq hl nil))        ;terminate the while at next iter
  637.       (setq hl (cdr hl)))))
  638.  
  639. (defvar Info-last-search nil
  640.   "Default regexp for \\<Info-mode-map>\\[Info-search] command to search for.")
  641.  
  642. (defun Info-search (regexp)
  643.   "Search for REGEXP, starting from point, and select node it's found in."
  644.   (interactive "sSearch (regexp): ")
  645.   (if (equal regexp "")
  646.       (setq regexp Info-last-search)
  647.     (setq Info-last-search regexp))
  648.   (let ((found ()) current
  649.     (onode Info-current-node)
  650.     (ofile Info-current-file)
  651.     (opoint (point))
  652.     (osubfile Info-current-subfile))
  653.     (save-excursion
  654.       (save-restriction
  655.     (widen)
  656.     (if (null Info-current-subfile)
  657.         (progn (re-search-forward regexp) (setq found (point)))
  658.       (condition-case err
  659.           (progn (re-search-forward regexp) (setq found (point)))
  660.         (search-failed nil)))))
  661.     (if (not found) ;can only happen in subfile case -- else would have erred
  662.     (unwind-protect
  663.         (let ((list ()))
  664.           (set-buffer (marker-buffer Info-tag-table-marker))
  665.           (goto-char (point-min))
  666.           (search-forward "\n\^_\nIndirect:")
  667.           (save-restriction
  668.         (narrow-to-region (point)
  669.                   (progn (search-forward "\n\^_")
  670.                      (1- (point))))
  671.         (goto-char (point-min))
  672.         (search-forward (concat "\n" osubfile ": "))
  673.         (beginning-of-line)
  674.         (while (not (eobp))
  675.           (re-search-forward "\\(^.*\\): [0-9]+$")
  676.           (goto-char (+ (match-end 1) 2))
  677.           (setq list (cons (cons (read (current-buffer))
  678.                      (buffer-substring (match-beginning 1)
  679.                                (match-end 1)))
  680.                    list))
  681.           (goto-char (1+ (match-end 0))))
  682.         (setq list (nreverse list)
  683.               current (car (car list))
  684.               list (cdr list)))
  685.           (while list
  686.         (message "Searching subfile %s..." (cdr (car list)))
  687.         (Info-read-subfile (car (car list)))
  688.         (setq list (cdr list))
  689. ;;        (goto-char (point-min))
  690.         (if (re-search-forward regexp nil t)
  691.             (setq found (point) list ())))
  692.           (if found
  693.           (message "")
  694.         (signal 'search-failed (list regexp))))
  695.       (if (not found)
  696.           (progn (Info-read-subfile opoint)
  697.              (goto-char opoint)
  698.              (Info-select-node)))))
  699.     (widen)
  700.     (goto-char found)
  701.     (Info-select-node)
  702.     (or (and (equal onode Info-current-node)
  703.          (equal ofile Info-current-file))
  704.     (setq Info-history (cons (list ofile onode opoint)
  705.                  Info-history)))))
  706.  
  707. ;; Extract the value of the node-pointer named NAME.
  708. ;; If there is none, use ERRORNAME in the error message; 
  709. ;; if ERRORNAME is nil, just return nil.
  710. (defun Info-extract-pointer (name &optional errorname)
  711.   (save-excursion
  712.    (goto-char (point-min))
  713.    (forward-line 1)
  714.    (if (re-search-backward (concat name ":") nil t)
  715.        (progn
  716.      (goto-char (match-end 0))
  717.      (Info-following-node-name))
  718.      (if (eq errorname t)
  719.      nil
  720.        (error (concat "Node has no " (capitalize (or errorname name))))))))
  721.  
  722. ;; Return the node name in the buffer following point.
  723. ;; ALLOWEDCHARS, if non-nil, goes within [...] to make a regexp
  724. ;; saying which chas may appear in the node name.
  725. (defun Info-following-node-name (&optional allowedchars)
  726.   (skip-chars-forward " \t")
  727.   (buffer-substring
  728.    (point)
  729.    (progn
  730.      (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]"))
  731.        (skip-chars-forward (concat (or allowedchars "^,\t\n") "("))
  732.        (if (looking-at "(")
  733.        (skip-chars-forward "^)")))
  734.      (skip-chars-backward " ")
  735.      (point))))
  736.  
  737. (defun Info-next ()
  738.   "Go to the next node of this node."
  739.   (interactive)
  740.   (Info-goto-node (Info-extract-pointer "next")))
  741.  
  742. (defun Info-prev ()
  743.   "Go to the previous node of this node."
  744.   (interactive)
  745.   (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous")))
  746.  
  747. (defun Info-up ()
  748.   "Go to the superior node of this node."
  749.   (interactive)
  750.   (Info-goto-node (Info-extract-pointer "up"))
  751.   (Info-restore-point Info-history))
  752.  
  753. (defun Info-last ()
  754.   "Go back to the last node visited."
  755.   (interactive)
  756.   (or Info-history
  757.       (error "This is the first Info node you looked at"))
  758.   (let (filename nodename opoint)
  759.     (setq filename (car (car Info-history)))
  760.     (setq nodename (car (cdr (car Info-history))))
  761.     (setq opoint (car (cdr (cdr (car Info-history)))))
  762.     (setq Info-history (cdr Info-history))
  763.     (Info-find-node filename nodename)
  764.     (setq Info-history (cdr Info-history))
  765.     (goto-char opoint)))
  766.  
  767. (defun Info-directory ()
  768.   "Go to the Info directory node."
  769.   (interactive)
  770.   (Info-find-node "dir" "top"))
  771.  
  772. (defun Info-follow-reference (footnotename)
  773.   "Follow cross reference named NAME to the node it refers to.
  774. NAME may be an abbreviation of the reference name."
  775.   (interactive
  776.    (let ((completion-ignore-case t)
  777.      completions default alt-default (start-point (point)) str i bol eol)
  778.      (save-excursion
  779.        ;; Store end and beginning of line.
  780.        (end-of-line)
  781.        (setq eol (point))
  782.        (beginning-of-line)
  783.        (setq bol (point))
  784.  
  785.        (goto-char (point-min))
  786.        (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t)
  787.      (setq str (buffer-substring
  788.             (match-beginning 1)
  789.             (1- (point))))
  790.      ;; See if this one should be the default.
  791.      (and (null default)
  792.           (<= (match-beginning 0) start-point)
  793.           (<= start-point (point))
  794.           (setq default t))
  795.      ;; See if this one should be the alternate default.
  796.      (and (null alt-default)
  797.           (and (<= bol (match-beginning 0))
  798.            (<= (point) eol))
  799.           (setq alt-default t))
  800.      (setq i 0)
  801.      (while (setq i (string-match "[ \n\t]+" str i))
  802.        (setq str (concat (substring str 0 i) " "
  803.                  (substring str (match-end 0))))
  804.        (setq i (1+ i)))
  805.      ;; Record as a completion and perhaps as default.
  806.      (if (eq default t) (setq default str))
  807.      (if (eq alt-default t) (setq alt-default str))
  808.      (setq completions
  809.            (cons (cons str nil)
  810.              completions))))
  811.      ;; If no good default was found, try an alternate.
  812.      (or default
  813.      (setq default alt-default))
  814.      ;; If only one cross-reference found, then make it default.
  815.      (if (eq (length completions) 1)
  816.          (setq default (car (car completions))))
  817.      (if completions
  818.      (let ((input (completing-read (if default
  819.                        (concat "Follow reference named: ("
  820.                            default ") ")
  821.                      "Follow reference named: ")
  822.                        completions nil t)))
  823.        (list (if (equal input "")
  824.              default input)))
  825.        (error "No cross-references in this node"))))
  826.   (let (target beg i (str (concat "\\*note " footnotename)))
  827.     (while (setq i (string-match " " str i))
  828.       (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i))))
  829.       (setq i (+ i 6)))
  830.     (save-excursion
  831.       (goto-char (point-min))
  832.       (or (re-search-forward str nil t)
  833.       (error "No cross-reference named %s" footnotename))
  834.       (goto-char (+ (match-beginning 0) 5))
  835.       (setq target
  836.         (Info-extract-menu-node-name "Bad format cross reference" t)))
  837.     (while (setq i (string-match "[ \t\n]+" target i))
  838.       (setq target (concat (substring target 0 i) " "
  839.                (substring target (match-end 0))))
  840.       (setq i (+ i 1)))
  841.     (Info-goto-node target)))
  842.  
  843. (defun Info-extract-menu-node-name (&optional errmessage multi-line)
  844.   (skip-chars-forward " \t\n")
  845.   (let ((beg (point))
  846.     str i)
  847.     (skip-chars-forward "^:")
  848.     (forward-char 1)
  849.     (setq str
  850.       (if (looking-at ":")
  851.           (buffer-substring beg (1- (point)))
  852.         (skip-chars-forward " \t\n")
  853.         (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n"))))
  854.     (while (setq i (string-match "\n" str i))
  855.       (aset str i ?\ ))
  856.     str))
  857.  
  858. ;; No one calls this.
  859. ;;(defun Info-menu-item-sequence (list)
  860. ;;  (while list
  861. ;;    (Info-menu (car list))
  862. ;;    (setq list (cdr list))))
  863.  
  864. (defun Info-complete-menu-item (string predicate action)
  865.   (let ((case-fold-search t))
  866.     (cond ((eq action nil)
  867.        (let (completions
  868.          (pattern (concat "\n\\* \\("
  869.                   (regexp-quote string)
  870.                   "[^:\t\n]*\\):")))
  871.          (save-excursion
  872.            (set-buffer Info-complete-menu-buffer)
  873.            (goto-char (point-min))
  874.            (while (re-search-forward pattern nil t)
  875.          (setq completions (cons (cons (format "%s"
  876.                                (buffer-substring
  877.                             (match-beginning 1)
  878.                             (match-end 1)))
  879.                            (match-beginning 1))
  880.                      completions))))
  881.          (try-completion string completions predicate)))
  882.       ((eq action t)
  883.        (let (completions
  884.          (pattern (concat "\n\\* \\("
  885.                   (regexp-quote string)
  886.                   "[^:\t\n]*\\):")))
  887.          (save-excursion
  888.            (set-buffer Info-complete-menu-buffer)
  889.            (goto-char (point-min))
  890.            (while (re-search-forward pattern nil t)
  891.          (setq completions (cons (cons (format "%s"
  892.                                (buffer-substring
  893.                             (match-beginning 1)
  894.                             (match-end 1)))
  895.                            (match-beginning 1))
  896.                      completions))))
  897.          (all-completions string completions predicate)))
  898.       (t
  899.        (save-excursion
  900.          (set-buffer Info-complete-menu-buffer)
  901.          (goto-char (point-min))
  902.          (re-search-forward (concat "\n\\* "
  903.                     (regexp-quote string)
  904.                     ":")
  905.                 nil t))))))
  906.  
  907.  
  908. (defun Info-menu (menu-item)
  909.   "Go to node for menu item named (or abbreviated) NAME.
  910. Completion is allowed, and the menu item point is on is the default."
  911.   (interactive
  912.    (let ((completions '())
  913.      ;; If point is within a menu item, use that item as the default
  914.      (default nil)
  915.      (p (point))
  916.      (last nil))
  917.      (save-excursion
  918.        (goto-char (point-min))
  919.        (if (not (search-forward "\n* menu:" nil t))
  920.        (error "No menu in this node"))
  921.        (setq beg (point))
  922.        (and (< (point) p)
  923.         (save-excursion
  924.           (goto-char p)
  925.           (end-of-line)
  926.           (re-search-backward "\n\\* \\([^:\t\n]*\\):" beg t)
  927.           (setq default (format "%s" (buffer-substring
  928.                       (match-beginning 1)
  929.                       (match-end 1)))))))
  930.      (let ((item nil))
  931.        (while (null item)
  932.      (setq item (let ((completion-ignore-case t)
  933.               (Info-complete-menu-buffer (current-buffer)))
  934.               (completing-read (if default
  935.                        (format "Menu item (default %s): "
  936.                            default)
  937.                        "Menu item: ")
  938.                        'Info-complete-menu-item nil t)))
  939.      ;; we rely on the fact that completing-read accepts an input
  940.      ;; of "" even when the require-match argument is true and ""
  941.      ;; is not a valid possibility
  942.      (if (string= item "")
  943.          (if default
  944.          (setq item default)
  945.              ;; ask again
  946.              (setq item nil))))
  947.        (list item))))
  948.   ;; there is a problem here in that if several menu items have the same
  949.   ;; name you can only go to the node of the first with this command.
  950.   (Info-goto-node (Info-extract-menu-item menu-item)))
  951.   
  952. (defun Info-extract-menu-item (menu-item)
  953.   (setq menu-item (regexp-quote menu-item))
  954.   (save-excursion
  955.     (goto-char (point-min))
  956.     (or (search-forward "\n* menu:" nil t)
  957.     (error "No menu in this node"))
  958.     (or (re-search-forward (concat "\n\\* " menu-item ":") nil t)
  959.     (re-search-forward (concat "\n\\* " menu-item) nil t)
  960.     (error "No such item in menu"))
  961.     (beginning-of-line)
  962.     (forward-char 2)
  963.     (Info-extract-menu-node-name)))
  964.  
  965. ;; If COUNT is nil, use the last item in the menu.
  966. (defun Info-extract-menu-counting (count)
  967.   (save-excursion
  968.     (goto-char (point-min))
  969.     (or (search-forward "\n* menu:" nil t)
  970.     (error "No menu in this node"))
  971.     (if count
  972.     (or (search-forward "\n* " nil t count)
  973.         (error "Too few items in menu"))
  974.       (while (search-forward "\n* " nil t)
  975.     nil))
  976.     (Info-extract-menu-node-name)))
  977.  
  978. (defun Info-nth-menu-item ()
  979.   "Go to the node of the Nth menu item.
  980. N is the digit argument used to invoke this command."
  981.   (interactive)
  982.   (Info-goto-node
  983.    (Info-extract-menu-counting
  984.     (- (aref (this-command-keys) (1- (length (this-command-keys)))) ?0))))
  985.  
  986. (defun Info-top-node ()
  987.   "Go to the Top node of this file."
  988.   (interactive)
  989.   (Info-goto-node "Top"))
  990.  
  991. (defun Info-final-node ()
  992.   "Go to the final node in this file."
  993.   (interactive)
  994.   (Info-goto-node "Top")
  995.   (let (Info-history)
  996.     ;; Go to the last node in the menu of Top.
  997.     (Info-goto-node (Info-extract-menu-counting nil))
  998.     ;; If the last node in the menu is not last in pointer structure,
  999.     ;; move forward until we can't go any farther. 
  1000.     (while (Info-forward-node t t) nil)
  1001.     ;; Then keep moving down to last subnode, unless we reach an index.
  1002.     (while (and (not (string-match "\\<index\\>" Info-current-node))
  1003.         (save-excursion (search-forward "\n* Menu:" nil t)))
  1004.       (Info-goto-node (Info-extract-menu-counting nil)))))
  1005.  
  1006. (defun Info-forward-node (&optional not-down no-error)
  1007.   "Go forward one node, considering all nodes as forming one sequence."
  1008.   (interactive)
  1009.   (goto-char (point-min))
  1010.   (forward-line 1)
  1011.   ;; three possibilities, in order of priority:
  1012.   ;;     1. next node is in a menu in this node (but not in an index)
  1013.   ;;     2. next node is next at same level
  1014.   ;;     3. next node is up and next
  1015.   (cond ((and (not not-down)
  1016.               (save-excursion (search-forward "\n* menu:" nil t))
  1017.           (not (string-match "\\<index\\>" Info-current-node)))
  1018.      (Info-goto-node (Info-extract-menu-counting 1))
  1019.          t)
  1020.         ((save-excursion (search-backward "next:" nil t))
  1021.          (Info-next)
  1022.          t)
  1023.         ((and (save-excursion (search-backward "up:" nil t))
  1024.           (not (equal (downcase (Info-extract-pointer "up")) "top")))
  1025.          (let ((old-node Info-current-node))
  1026.            (Info-up)
  1027.            (let (Info-history success)
  1028.              (unwind-protect
  1029.                  (setq success (Info-forward-node t no-error))
  1030.                (or success (Info-goto-node old-node))))))
  1031.         (no-error nil)
  1032.         (t (error "No pointer forward from this node"))))
  1033.  
  1034. (defun Info-backward-node ()
  1035.   "Go backward one node, considering all nodes as forming one sequence."
  1036.   (interactive)
  1037.   (let ((prevnode (Info-extract-pointer "prev[ious]*" t))
  1038.     (upnode (Info-extract-pointer "up" t)))
  1039.     (cond ((and upnode (string-match "(" upnode))
  1040.        (error "First node in file"))
  1041.       ((and upnode (or (null prevnode)
  1042.                (equal (downcase prevnode) (downcase upnode))))
  1043.        (Info-up))
  1044.       (prevnode
  1045.        ;; If we move back at the same level,
  1046.        ;; go down to find the last subnode*.
  1047.        (Info-prev)
  1048.        (let (Info-history)
  1049.          (while (and (not (string-match "\\<index\\>" Info-current-node))
  1050.              (save-excursion (search-forward "\n* Menu:" nil t)))
  1051.            (Info-goto-node (Info-extract-menu-counting nil)))))
  1052.       (t
  1053.        (error "No pointer backward from this node")))))
  1054.  
  1055. (defun Info-exit ()
  1056.   "Exit Info by selecting some other buffer."
  1057.   (interactive)
  1058.   (if Info-standalone
  1059.       (save-buffers-kill-emacs)
  1060.     (switch-to-buffer (prog1 (other-buffer (current-buffer))
  1061.             (bury-buffer (current-buffer))))))
  1062.  
  1063. (defun Info-next-menu-item ()
  1064.   (interactive)
  1065.   (save-excursion
  1066.     (forward-line -1)
  1067.     (search-forward "\n* menu:" nil t)
  1068.     (or (search-forward "\n* " nil t)
  1069.     (error "No more items in menu"))
  1070.     (Info-goto-node (Info-extract-menu-node-name))))
  1071.  
  1072. (defun Info-last-menu-item ()
  1073.   (interactive)
  1074.   (save-excursion
  1075.     (forward-line 1)
  1076.     (let ((beg (save-excursion
  1077.          (and (search-backward "\n* menu:" nil t)
  1078.               (point)))))
  1079.       (or (and beg (search-backward "\n* " beg t))
  1080.       (error "No previous items in menu")))
  1081.     (Info-goto-node (save-excursion
  1082.               (goto-char (match-end 0))
  1083.               (Info-extract-menu-node-name)))))
  1084.  
  1085. (defmacro Info-no-error (&rest body)
  1086.   (list 'condition-case nil (cons 'progn (append body '(t))) '(error nil)))
  1087.  
  1088. (defun Info-next-preorder ()
  1089.   "Go to the next subnode, popping up a level if there is none."
  1090.   (interactive)
  1091.   (cond ((Info-no-error (Info-next-menu-item)))
  1092.     ((Info-no-error (Info-up))
  1093.      (forward-line 1))
  1094.     (t
  1095.      (error "No more nodes"))))
  1096.  
  1097. (defun Info-next-preorder-1 ()
  1098.   "Go to the next subnode or the next node, or go up a level."
  1099.   (interactive)
  1100.   (cond ((Info-no-error (Info-next-menu-item)))
  1101.     ((Info-no-error (Info-next)))
  1102.     ((Info-no-error (Info-up))
  1103.      (forward-line 1))
  1104.     (t
  1105.      (error "No more nodes"))))
  1106.  
  1107. (defun Info-last-preorder ()
  1108.   "Go to the last node, popping up a level if there is none."
  1109.   (interactive)
  1110.   (cond ((Info-no-error
  1111.       (Info-last-menu-item)
  1112.       ;; If we go down a menu item, go to the end of the node
  1113.       ;; so we can scroll back through it.
  1114.       (goto-char (point-max))))
  1115.     ((Info-no-error (Info-up))        (forward-line -1))
  1116.     (t                     (error "No previous nodes"))))
  1117.  
  1118. (defun Info-scroll-up ()
  1119.   "Read the next screen.  If end of buffer is visible, go to next entry."
  1120.   (interactive)
  1121.   (if (or (< (window-start) (point-min))
  1122.       (> (window-start) (point-max)))
  1123.       (set-window-start (selected-window) (point)))
  1124.   (let ((virtual-end (save-excursion
  1125.                (goto-char (point-min))
  1126.                (if (search-forward "\n* Menu:" nil t)
  1127.                (point)
  1128.              (point-max)))))
  1129.     (if (or (< virtual-end (window-start))
  1130.         (pos-visible-in-window-p virtual-end))
  1131.     (Info-next-preorder)
  1132.       (scroll-up))))
  1133.  
  1134. (defun Info-scroll-down ()
  1135.   "Read the previous screen.  If start of buffer is visible, go to last entry."
  1136.   (interactive)
  1137.   (if (or (< (window-start) (point-min))
  1138.       (> (window-start) (point-max)))
  1139.       (set-window-start (selected-window) (point)))
  1140.   (let ((virtual-end (save-excursion
  1141.                (goto-char (point-min))
  1142.                (search-forward "\n* Menu:" nil t))))
  1143.     (if (or virtual-end (pos-visible-in-window-p (point-min)))
  1144.     (Info-last-preorder)
  1145.       (scroll-down))))
  1146.  
  1147. (defun Info-next-reference ()
  1148.   "Move cursor to the next cross-reference or menu item in the node."
  1149.   (interactive)
  1150.   (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
  1151.     (old-pt (point)))
  1152.     (or (eobp) (forward-char 1))
  1153.     (or (re-search-forward pat nil t)
  1154.     (progn
  1155.       (goto-char (point-min))
  1156.       (or (re-search-forward pat nil t)
  1157.           (progn
  1158.         (goto-char old-pt)
  1159.         (error "No cross references in this node")))))
  1160.     (goto-char (match-beginning 0))
  1161.     (if (looking-at "\\* Menu:")
  1162.     (Info-next-reference))))
  1163.  
  1164. (defun Info-prev-reference ()
  1165.   "Move cursor to the previous cross-reference or menu item in the node."
  1166.   (interactive)
  1167.   (let ((pat "\\*note[ \n\t]*\\([^:]*\\):\\|^\\* .*:")
  1168.     (old-pt (point)))
  1169.     (or (re-search-backward pat nil t)
  1170.     (progn
  1171.       (goto-char (point-max))
  1172.       (or (re-search-backward pat nil t)
  1173.           (progn
  1174.         (goto-char old-pt)
  1175.         (error "No cross references in this node")))))
  1176.     (goto-char (match-beginning 0))
  1177.     (if (looking-at "\\* Menu:")
  1178.     (Info-prev-reference))))
  1179.  
  1180. (defun Info-index (topic)
  1181.   "Look up a string in the index for this file.
  1182. The index is defined as the first node in the top-level menu whose
  1183. name contains the word \"Index\", plus any immediately following
  1184. nodes whose names also contain the word \"Index\".
  1185. If there are no exact matches to the specified topic, this chooses
  1186. the first match which is a case-insensitive substring of a topic.
  1187. Use the `,' command to see the other matches.
  1188. Give a blank topic name to go to the Index node itself."
  1189.   (interactive "sIndex topic: ")
  1190.   (let ((orignode Info-current-node)
  1191.     (rnode nil)
  1192.     (pattern (format "\n\\* \\([^\n:]*%s[^\n:]*\\):[ \t]*\\([^.\n]*\\)\\.[ \t]*\\([0-9]*\\)"
  1193.              (regexp-quote topic)))
  1194.     node)
  1195.     (Info-goto-node "Top")
  1196.     (or (search-forward "\n* menu:" nil t)
  1197.     (error "No index"))
  1198.     (or (re-search-forward "\n\\* \\(.*\\<Index\\>\\)" nil t)
  1199.     (error "No index"))
  1200.     (goto-char (match-beginning 1))
  1201.     (let ((Info-keeping-history nil))
  1202.       (Info-goto-node (Info-extract-menu-node-name)))
  1203.     (or (equal topic "")
  1204.     (let ((matches nil)
  1205.           (exact nil)
  1206.           (Info-keeping-history nil)
  1207.           found)
  1208.       (while
  1209.           (progn
  1210.         (goto-char (point-min))
  1211.         (while (re-search-forward pattern nil t)
  1212.           (setq matches
  1213.             (cons (list (buffer-substring (match-beginning 1)
  1214.                               (match-end 1))
  1215.                     (buffer-substring (match-beginning 2)
  1216.                               (match-end 2))
  1217.                     Info-current-node
  1218.                     (string-to-int (concat "0"
  1219.                                (buffer-substring
  1220.                                 (match-beginning 3)
  1221.                                 (match-end 3)))))
  1222.                   matches)))
  1223.         (and (setq node (Info-extract-pointer "next" t))
  1224.              (string-match "\\<Index\\>" node)))
  1225.         (Info-goto-node node))
  1226.       (or matches
  1227.           (progn
  1228.         (Info-last)
  1229.         (error "No \"%s\" in index" topic)))
  1230.       ;; Here it is a feature that assoc is case-sensitive.
  1231.       (while (setq found (assoc topic matches))
  1232.         (setq exact (cons found exact)
  1233.           matches (delq found matches)))
  1234.       (setq Info-index-alternatives (nconc exact (nreverse matches)))
  1235.       (Info-index-next 0)))))
  1236.  
  1237. (defun Info-index-next (num)
  1238.   "Go to the next matching index item from the last `i' command."
  1239.   (interactive "p")
  1240.   (or Info-index-alternatives
  1241.       (error "No previous `i' command in this file"))
  1242.   (while (< num 0)
  1243.     (setq num (+ num (length Info-index-alternatives))))
  1244.   (while (> num 0)
  1245.     (setq Info-index-alternatives
  1246.       (nconc (cdr Info-index-alternatives)
  1247.          (list (car Info-index-alternatives)))
  1248.       num (1- num)))
  1249.   (Info-goto-node (nth 1 (car Info-index-alternatives)))
  1250.   (if (> (nth 3 (car Info-index-alternatives)) 0)
  1251.       (forward-line (nth 3 (car Info-index-alternatives)))
  1252.     (forward-line 3)  ; don't search in headers
  1253.     (let ((name (car (car Info-index-alternatives))))
  1254.       (if (or (re-search-forward (format
  1255.                   "\\(Function\\|Command\\): %s\\( \\|$\\)"
  1256.                   (regexp-quote name)) nil t)
  1257.           (search-forward (format "`%s'" name) nil t)
  1258.           (and (string-match "\\`.*\\( (.*)\\)\\'" name)
  1259.            (search-forward
  1260.             (format "`%s'" (substring name 0 (match-beginning 1)))
  1261.             nil t))
  1262.           (search-forward name nil t))
  1263.       (beginning-of-line)
  1264.     (goto-char (point-min)))))
  1265.   (message "Found \"%s\" in %s.  %s"
  1266.        (car (car Info-index-alternatives))
  1267.        (nth 2 (car Info-index-alternatives))
  1268.        (if (cdr Info-index-alternatives)
  1269.            "(Press `,' for more)"
  1270.          "(Only match)")))
  1271.  
  1272. (defun Info-undefined ()
  1273.   "Make command be undefined in Info."
  1274.   (interactive)
  1275.   (ding))
  1276.  
  1277. (defun Info-help ()
  1278.   "Enter the Info tutorial."
  1279.   (interactive)
  1280.   (delete-other-windows)
  1281.   (Info-find-node "info"
  1282.           (if (< (window-height) 23)
  1283.               "Help-Small-Screen"
  1284.             "Help")))
  1285.  
  1286. (defun Info-summary ()
  1287.   "Display a brief summary of all Info commands."
  1288.   (interactive)
  1289.   (save-window-excursion
  1290.     (switch-to-buffer "*Help*")
  1291.     (erase-buffer)
  1292.     (insert (documentation 'Info-mode))
  1293.     (goto-char (point-min))
  1294.     (let (ch flag)
  1295.       (while (progn (setq flag (not (pos-visible-in-window-p (point-max))))
  1296.             (message (if flag "Type Space to see more"
  1297.                    "Type Space to return to Info"))
  1298.             (if (not (eq ?\  (setq ch (read-event))))
  1299.             (progn (setq unread-command-events (list ch)) nil)
  1300.               flag))
  1301.     (scroll-up)))
  1302.     (bury-buffer "*Help*")))
  1303.  
  1304. (defun Info-get-token (pos start all &optional errorstring)
  1305.   "Return the token around POS,
  1306. POS must be somewhere inside the token
  1307. START is a regular expression which will match the
  1308.     beginning of the tokens delimited string
  1309. ALL is a regular expression with a single
  1310.     parenthized subpattern which is the token to be
  1311.     returned. E.g. '{\(.*\)}' would return any string
  1312.     enclosed in braces around POS.
  1313. SIG optional fourth argument, controls action on no match
  1314.     nil: return nil
  1315.     t: beep
  1316.     a string: signal an error, using that string."
  1317.   (save-excursion
  1318.     (goto-char pos)
  1319.     (re-search-backward start (max (point-min) (- pos 200)) 'yes)
  1320.     (let (found)
  1321.       (while (and (re-search-forward all (min (point-max) (+ pos 200)) 'yes)
  1322.           (not (setq found (and (<= (match-beginning 0) pos)
  1323.                     (> (match-end 0) pos))))))
  1324.       (if (and found (<= (match-beginning 0) pos)
  1325.            (> (match-end 0) pos))
  1326.       (buffer-substring (match-beginning 1) (match-end 1))
  1327.     (cond ((null errorstring)
  1328.            nil)
  1329.           ((eq errorstring t)
  1330.            (beep)
  1331.            nil)
  1332.           (t
  1333.            (error "No %s around position %d" errorstring pos)))))))
  1334.  
  1335. (defun Info-mouse-follow-nearest-node (click)
  1336.   "\\<Info-mode-map>Follow a node reference near point.
  1337. Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where you click.
  1338. At end of the node's text, moves to the next node, or up if none."
  1339.   (interactive "e")
  1340.   (let* ((start (event-start click))
  1341.      (window (car start))
  1342.      (pos (car (cdr start))))
  1343.     (select-window window)
  1344.     (goto-char pos))
  1345.   (and (not (Info-try-follow-nearest-node))
  1346.        (save-excursion (forward-line 1) (eobp))
  1347.        (Info-next-preorder-1)))
  1348.  
  1349. (defun Info-follow-nearest-node ()
  1350.   "\\<Info-mode-map>Follow a node reference near point.
  1351. Like \\[Info-menu], \\[Info-follow-reference], \\[Info-next], \\[Info-prev] or \\[Info-up] command, depending on where point is.
  1352. If no reference to follow, moves to the next node, or up if none."
  1353.   (interactive)
  1354.   (or (Info-try-follow-nearest-node)
  1355.       (Info-next-preorder-1)))
  1356.  
  1357. ;; Common subroutine.
  1358. (defun Info-try-follow-nearest-node ()
  1359.   "Follow a node reference near point.  Return non-nil if successful."
  1360.   (let (node)
  1361.     (cond
  1362.      ((setq node (Info-get-token (point) "\\*note[ \n]"
  1363.                  "\\*note[ \n]\\([^:]*\\):"))
  1364.       (Info-follow-reference node))
  1365.      ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\)::"))
  1366.       (Info-goto-node node))
  1367.      ((setq node (Info-get-token (point) "\\* " "\\* \\([^:]*\\):"))
  1368.       (Info-menu node))
  1369.      ((setq node (Info-get-token (point) "Up: " "Up: \\([^,\n\t]*\\)"))
  1370.       (Info-goto-node node))
  1371.      ((setq node (Info-get-token (point) "Next: " "Next: \\([^,\n\t]*\\)"))
  1372.       (Info-goto-node node))
  1373.      ((setq node (Info-get-token (point) "File: " "File: \\([^,\n\t]*\\)"))
  1374.       (Info-goto-node "Top"))
  1375.      ((setq node (Info-get-token (point) "Prev: " "Prev: \\([^,\n\t]*\\)"))
  1376.       (Info-goto-node node)))
  1377.     node))
  1378.  
  1379. (defvar Info-mode-map nil
  1380.   "Keymap containing Info commands.")
  1381. (if Info-mode-map
  1382.     nil
  1383.   (setq Info-mode-map (make-keymap))
  1384.   (suppress-keymap Info-mode-map)
  1385.   (define-key Info-mode-map "." 'beginning-of-buffer)
  1386.   (define-key Info-mode-map " " 'Info-scroll-up)
  1387.   (define-key Info-mode-map "\C-m" 'Info-follow-nearest-node)
  1388.   (define-key Info-mode-map "\t" 'Info-next-reference)
  1389.   (define-key Info-mode-map "\e\t" 'Info-prev-reference)
  1390.   (define-key Info-mode-map "1" 'Info-nth-menu-item)
  1391.   (define-key Info-mode-map "2" 'Info-nth-menu-item)
  1392.   (define-key Info-mode-map "3" 'Info-nth-menu-item)
  1393.   (define-key Info-mode-map "4" 'Info-nth-menu-item)
  1394.   (define-key Info-mode-map "5" 'Info-nth-menu-item)
  1395.   (define-key Info-mode-map "6" 'Info-nth-menu-item)
  1396.   (define-key Info-mode-map "7" 'Info-nth-menu-item)
  1397.   (define-key Info-mode-map "8" 'Info-nth-menu-item)
  1398.   (define-key Info-mode-map "9" 'Info-nth-menu-item)
  1399.   (define-key Info-mode-map "0" 'undefined)
  1400.   (define-key Info-mode-map "?" 'Info-summary)
  1401.   (define-key Info-mode-map "]" 'Info-forward-node)
  1402.   (define-key Info-mode-map "[" 'Info-backward-node)
  1403.   (define-key Info-mode-map "<" 'Info-top-node)
  1404.   (define-key Info-mode-map ">" 'Info-final-node)
  1405.   (define-key Info-mode-map "b" 'beginning-of-buffer)
  1406.   (define-key Info-mode-map "d" 'Info-directory)
  1407.   (define-key Info-mode-map "e" 'Info-edit)
  1408.   (define-key Info-mode-map "f" 'Info-follow-reference)
  1409.   (define-key Info-mode-map "g" 'Info-goto-node)
  1410.   (define-key Info-mode-map "h" 'Info-help)
  1411.   (define-key Info-mode-map "i" 'Info-index)
  1412.   (define-key Info-mode-map "l" 'Info-last)
  1413.   (define-key Info-mode-map "m" 'Info-menu)
  1414.   (define-key Info-mode-map "n" 'Info-next)
  1415.   (define-key Info-mode-map "p" 'Info-prev)
  1416.   (define-key Info-mode-map "q" 'Info-exit)
  1417.   (define-key Info-mode-map "s" 'Info-search)
  1418.   (define-key Info-mode-map "t" 'Info-top-node)
  1419.   (define-key Info-mode-map "u" 'Info-up)
  1420.   (define-key Info-mode-map "," 'Info-index-next)
  1421.   (define-key Info-mode-map "\177" 'Info-scroll-down)
  1422.   (define-key Info-mode-map [mouse-2] 'Info-mouse-follow-nearest-node)
  1423.   )
  1424.  
  1425. ;; Info mode is suitable only for specially formatted data.
  1426. (put 'info-mode 'mode-class 'special)
  1427.  
  1428. (defun Info-mode ()
  1429.   "\\<Info-mode-map>
  1430. Info mode provides commands for browsing through the Info documentation tree.
  1431. Documentation in Info is divided into \"nodes\", each of which discusses
  1432. one topic and contains references to other nodes which discuss related
  1433. topics.  Info has commands to follow the references and show you other nodes.
  1434.  
  1435. \\[Info-help]    Invoke the Info tutorial.
  1436.  
  1437. Selecting other nodes:
  1438. \\[Info-mouse-follow-nearest-node]
  1439.     Follow a node reference you click on.
  1440.       This works with menu items, cross references, and
  1441.       the \"next\", \"previous\" and \"up\", depending on where you click.
  1442. \\[Info-next]    Move to the \"next\" node of this node.
  1443. \\[Info-prev]    Move to the \"previous\" node of this node.
  1444. \\[Info-up]    Move \"up\" from this node.
  1445. \\[Info-menu]    Pick menu item specified by name (or abbreviation).
  1446.     Picking a menu item causes another node to be selected.
  1447. \\[Info-directory]    Go to the Info directory node.
  1448. \\[Info-follow-reference]    Follow a cross reference.  Reads name of reference.
  1449. \\[Info-last]    Move to the last node you were at.
  1450. \\[Info-index]    Look up a topic in this file's Index and move to that node.
  1451. \\[Info-index-next]    (comma) Move to the next match from a previous `i' command.
  1452.  
  1453. Moving within a node:
  1454. \\[Info-scroll-up]    Normally, scroll forward a full screen.  If the end of the buffer is
  1455. already visible, try to go to the next menu entry, or up if there is none.
  1456. \\[Info-scroll-down]  Normally, scroll backward.  If the beginning of the buffer is
  1457. already visible, try to go to the previous menu entry, or up if there is none.
  1458. \\[beginning-of-buffer]    Go to beginning of node.  
  1459.  
  1460. Advanced commands:
  1461. \\[Info-exit]    Quit Info: reselect previously selected buffer.
  1462. \\[Info-edit]    Edit contents of selected node.
  1463. 1    Pick first item in node's menu.
  1464. 2, 3, 4, 5   Pick second ... fifth item in node's menu.
  1465. \\[Info-goto-node]    Move to node specified by name.
  1466.     You may include a filename as well, as (FILENAME)NODENAME.
  1467. \\[universal-argument] \\[info]    Move to new Info file with completion.
  1468. \\[Info-search]    Search through this Info file for specified regexp,
  1469.     and select the node in which the next occurrence is found.
  1470. \\[Info-next-preorder]    Next-preorder; that is, try to go to the next menu item,
  1471.     and if that fails try to move up, and if that fails, tell user
  1472.      he/she is done reading.
  1473. \\[Info-next-reference]    Move cursor to next cross-reference or menu item.
  1474. \\[Info-prev-reference]    Move cursor to previous cross-reference or menu item."
  1475.   (kill-all-local-variables)
  1476.   (setq major-mode 'Info-mode)
  1477.   (setq mode-name "Info")
  1478.   (use-local-map Info-mode-map)
  1479.   (set-syntax-table text-mode-syntax-table)
  1480.   (setq local-abbrev-table text-mode-abbrev-table)
  1481.   (setq case-fold-search t)
  1482.   (setq buffer-read-only t)
  1483.   (make-local-variable 'Info-current-file)
  1484.   (make-local-variable 'Info-current-subfile)
  1485.   (make-local-variable 'Info-current-node)
  1486.   (make-local-variable 'Info-tag-table-marker)
  1487.   (make-local-variable 'Info-history)
  1488.   (make-local-variable 'Info-index-alternatives)
  1489.   (if (eq (framep (selected-frame)) 'x)
  1490.       (progn
  1491.     (make-face 'info-node)
  1492.     (make-face 'info-menu-5)
  1493.     (make-face 'info-xref)
  1494.     (or (face-differs-from-default-p 'info-node)
  1495.         (if (face-differs-from-default-p 'bold-italic)
  1496.         (copy-face 'bold-italic 'info-node)
  1497.           (copy-face 'bold 'info-node)))
  1498.     (or (face-differs-from-default-p 'info-menu-5)
  1499.         (set-face-underline-p 'info-menu-5 t))
  1500.     (or (face-differs-from-default-p 'info-xref)
  1501.         (copy-face 'bold 'info-xref)))
  1502.     (setq Info-fontify nil))
  1503.   (Info-set-mode-line)
  1504.   (run-hooks 'Info-mode-hook))
  1505.  
  1506. (defvar Info-edit-map nil
  1507.   "Local keymap used within `e' command of Info.")
  1508. (if Info-edit-map
  1509.     nil
  1510.   (setq Info-edit-map (nconc (make-sparse-keymap) text-mode-map))
  1511.   (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit))
  1512.  
  1513. ;; Info-edit mode is suitable only for specially formatted data.
  1514. (put 'info-edit-mode 'mode-class 'special)
  1515.  
  1516. (defun Info-edit-mode ()
  1517.   "Major mode for editing the contents of an Info node.
  1518. Like text mode with the addition of `Info-cease-edit'
  1519. which returns to Info mode for browsing.
  1520. \\{Info-edit-map}"
  1521.   )
  1522.  
  1523. (defun Info-edit ()
  1524.   "Edit the contents of this Info node.
  1525. Allowed only if variable `Info-enable-edit' is non-nil."
  1526.   (interactive)
  1527.   (or Info-enable-edit
  1528.       (error "Editing info nodes is not enabled"))
  1529.   (use-local-map Info-edit-map)
  1530.   (setq major-mode 'Info-edit-mode)
  1531.   (setq mode-name "Info Edit")
  1532.   (kill-local-variable 'mode-line-buffer-identification)
  1533.   (setq buffer-read-only nil)
  1534.   ;; Make mode line update.
  1535.   (set-buffer-modified-p (buffer-modified-p))
  1536.   (message (substitute-command-keys
  1537.          "Editing: Type \\<Info-edit-map>\\[Info-cease-edit] to return to info")))
  1538.  
  1539. (defun Info-cease-edit ()
  1540.   "Finish editing Info node; switch back to Info proper."
  1541.   (interactive)
  1542.   ;; Do this first, so nothing has changed if user C-g's at query.
  1543.   (and (buffer-modified-p)
  1544.        (y-or-n-p "Save the file? ")
  1545.        (save-buffer))
  1546.   (use-local-map Info-mode-map)
  1547.   (setq major-mode 'Info-mode)
  1548.   (setq mode-name "Info")
  1549.   (Info-set-mode-line)
  1550.   (setq buffer-read-only t)
  1551.   ;; Make mode line update.
  1552.   (set-buffer-modified-p (buffer-modified-p))
  1553.   (and (marker-position Info-tag-table-marker)
  1554.        (buffer-modified-p)
  1555.        (message "Tags may have changed.  Use Info-tagify if necessary")))
  1556.  
  1557. (defun Info-find-emacs-command-nodes (command)
  1558.   "Return a list of locations documenting COMMAND in the Emacs Info manual.
  1559. The locations are of the format used in Info-history, i.e.
  1560. \(FILENAME NODENAME BUFFERPOS\)."
  1561.   (require 'info)
  1562.   (let ((where '())
  1563.     (cmd-desc (concat "^\\* " (regexp-quote (symbol-name command))
  1564.               ":\\s *\\(.*\\)\\.$")))
  1565.     (save-excursion
  1566.       (Info-find-node "emacs" "Command Index")
  1567.       ;; Take the index node off the Info history.
  1568.       (setq Info-history (cdr Info-history))
  1569.       (goto-char (point-max))
  1570.       (while (re-search-backward cmd-desc nil t)
  1571.       (setq where (cons (list Info-current-file
  1572.                   (buffer-substring
  1573.                    (match-beginning 1)
  1574.                    (match-end 1))
  1575.                   0)
  1576.                 where)))
  1577.       where)))
  1578.  
  1579. ;;;###autoload
  1580. (defun Info-goto-emacs-command-node (command)
  1581.   "Go to the Info node in the Emacs manual for command COMMAND.
  1582. The command is found by looking up in Emacs manual's Command Index."
  1583.   (interactive "CFind documentation for command: ")
  1584.   (or (commandp command)
  1585.       (signal 'wrong-type-argument (list 'commandp command)))
  1586.   (let ((where (Info-find-emacs-command-nodes command)))
  1587.     (if where
  1588.     (let ((num-matches (length where)))
  1589.       ;; Get Info running, and pop to it in another window.
  1590.       (save-window-excursion
  1591.         (info))
  1592.       (pop-to-buffer "*info*")
  1593.       (Info-find-node (car (car where))
  1594.               (car (cdr (car where))))
  1595.       (if (> num-matches 1)
  1596.           (progn
  1597.         ;; Info-find-node already pushed (car where) onto
  1598.         ;; Info-history.  Put the other nodes that were found on
  1599.         ;; the history.
  1600.         (setq Info-history (nconc (cdr where) Info-history))
  1601.         (message (substitute-command-keys
  1602.               "Found %d other entr%s.  Use \\[Info-last] to see %s.")
  1603.              (1- num-matches)
  1604.              (if (> num-matches 2) "ies" "y")
  1605.              (if (> num-matches 2) "them" "it")))))
  1606.       (error "Couldn't find documentation for %s." command))))
  1607.  
  1608. ;;;###autoload
  1609. (defun Info-goto-emacs-key-command-node (key)
  1610.   "Go to the Info node in the Emacs manual the command bound to KEY, a string.
  1611. Interactively, if the binding is execute-extended-command, a command is read.
  1612. The command is found by looking up in Emacs manual's Command Index."
  1613.   (interactive "kFind documentation for key:")
  1614.   (let ((command (key-binding key)))
  1615.     (cond ((null command)
  1616.        (message "%s is undefined" (key-description key)))
  1617.       ((and (interactive-p)
  1618.         (eq command 'execute-extended-command))
  1619.        (Info-goto-emacs-command-node
  1620.         (read-command "Find documentation for command: ")))
  1621.       (t
  1622.        (Info-goto-emacs-command-node command)))))
  1623.  
  1624. (defun Info-fontify-node ()
  1625.   (save-excursion
  1626.     (let ((buffer-read-only nil))
  1627.       (goto-char (point-min))
  1628.       (if (looking-at "^File: [^,: \t]+,?[ \t]+")
  1629.       (progn
  1630.         (goto-char (match-end 0))
  1631.         (while
  1632.         (looking-at "[ \t]*[^:, \t\n]+:[ \t]+\\([^:,\t\n]+\\),?")
  1633.           (goto-char (match-end 0))
  1634.           (put-text-property (match-beginning 1) (match-end 1)
  1635.                  'face 'info-xref)
  1636.           (put-text-property (match-beginning 1) (match-end 1)
  1637.                  'mouse-face 'highlight))))
  1638.       (goto-char (point-min))
  1639.       (while (re-search-forward "\\*Note[ \n\t]+\\([^:]*\\):" nil t)
  1640.     (if (= (char-after (1- (match-beginning 0))) ?\") ; hack
  1641.         nil
  1642.       (put-text-property (match-beginning 1) (match-end 1)
  1643.                  'face 'info-xref)
  1644.       (put-text-property (match-beginning 1) (match-end 1)
  1645.                  'mouse-face 'highlight)))
  1646.       (goto-char (point-min))
  1647.       (if (and (search-forward "\n* Menu:" nil t)
  1648.            (not (string-match "\\<Index\\>" Info-current-node))
  1649.            ;; Don't take time to annotate huge menus
  1650.            (< (- (point-max) (point)) Info-fontify-maximum-menu-size))
  1651.       (let ((n 0))
  1652.         (while (re-search-forward "^\\* \\([^:\t\n]*\\):" nil t)
  1653.           (setq n (1+ n))
  1654.           (if (memq n '(5 9))   ; visual aids to help with 1-9 keys
  1655.           (put-text-property (match-beginning 0)
  1656.                      (1+ (match-beginning 0))
  1657.                      'face 'info-menu-5))
  1658.           (put-text-property (match-beginning 1) (match-end 1)
  1659.                  'face 'info-node)
  1660.           (put-text-property (match-beginning 1) (match-end 1)
  1661.                  'mouse-face 'highlight))))
  1662.       (set-buffer-modified-p nil))))
  1663.  
  1664. (provide 'info)
  1665.  
  1666. ;;; info.el ends here
  1667.